package cn.regexp.marktag.provider;

import cn.regexp.marktag.decorator.CoreFileDecorator;
import com.intellij.ide.projectView.ProjectViewNode;
import com.intellij.ide.projectView.TreeStructureProvider;
import com.intellij.ide.projectView.ViewSettings;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

/**
 * @author Regexpei
 * @date 2024/4/30 22:39
 * @description 核心文件修饰提供者
 */
public class CoreFileProvider implements TreeStructureProvider {
    @Override
    public @NotNull Collection<AbstractTreeNode<?>> modify(@NotNull AbstractTreeNode<?> abstractTreeNode,
                                                           @NotNull Collection<AbstractTreeNode<?>> collection,
                                                           ViewSettings viewSettings) {
        for (AbstractTreeNode<?> node : collection) {
            CoreFileDecorator.setStyle((ProjectViewNode<?>) node);
        }

        return collection;
    }

    @Override
    public @Nullable Object getData(@NotNull Collection<? extends AbstractTreeNode<?>> selected, @NotNull String dataId) {
        for (AbstractTreeNode<?> node : selected) {
            CoreFileDecorator.setStyle((ProjectViewNode<?>) node);
        }
        return TreeStructureProvider.super.getData(selected, dataId);
    }
}
